package com.jxzn.locust.service.impl;

import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jxzn.locust.dao.AbstractRepository;
import com.jxzn.locust.dao.PlayerRepository;
import com.jxzn.locust.model.Player;
import com.jxzn.locust.service.PlayerService;

@Service
@Transactional
public class PlayerServiceImpl implements PlayerService {

    @Autowired
    PlayerRepository playerRepository;

    @Override
    public AbstractRepository<Player> getRepository() {
        return playerRepository;
    }

    @Override
    public Player findByMobile(String mobile) {
        List<Player> playerList = playerRepository.findByMobile(mobile);
        if (CollectionUtils.isEmpty(playerList)) {
            return null;
        }
        return playerList.get(0);
    }

}
